package org.restorator.dao.jdbc;

import org.restorator.exception.DataStoreException;

import java.sql.ResultSet;
import java.util.List;

/**
 * Extractor that extract data from {@link ResultSet} to some entity.
 * Should to use {@link RowMapper} mapper for mapping each row to entity object.
 *
 * @author Snisar Bogdan
 */
public interface ResultSetExtractor {

    /**
     *  Extract entities from each rows as paramList. If ResultSet is empty will returns empty paramList.
     *
     * @param rs {@link ResultSet} resultSet of sql query.
     * @return List entities.
     */
    List<Object> extractData(ResultSet rs) throws DataStoreException;

    /**
     * Extract first row of result set. Used for single sql query results.
     *
     * @param rs {@link ResultSet} resultSet of sql query.
     * @return entity by first row, or null If result set is empty
     */
    Object extractFirst(ResultSet rs) throws DataStoreException;



}
